<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>后台管理 - 开心买</title>
<link type="text/css" rel="stylesheet" href="${project_name}/css/style.css" />
<script type="text/javascript" src="${project_name}/js/jquery-1.8.3.js"></script>
<script>$(function(){$('.clearfix li:eq(2)').addClass('current');});</script>
<link href="${project_name}/pagination/pagination.min.css" rel="stylesheet">
<script src="${project_name}/pagination/pagination.js"></script>
<script>
	$(function () {
		$("summary").click(function () {
			var str=$(this).find("input").val()
			var that=this
			$.ajax({
				url:'${project_name}/back_type/findSecond/'+str,
				type: 'post',    // 请求方式
				traditional:true,
				async: true,    // 默认true 异步请求 同步为false
				success: function (data) {
					JSON.stringify(data);
					var list = data.json1;
					var str=''
					for (var i = 0; i < list.length; i++) {
						str+='<p>' +list[i].name+
								'<span style="float: right;">\n' +
								'<a href="${project_name}/back_type/showOneSecondaryType/'+list[i].id+'/'+list[i].firstTypeId+'">修改</a>\n' +
								'<a href="${project_name}/back_type/delSecondaryType/'+list[i].id+'" onclick="return confirm(\'确定删除?\')">删除</a>\n' +
								'</span>\n' +
								'</p>'
					}
					if($(that).parent().find("p").length != 0){
						$(that).parent().find("p").remove()
					}else
						$(that).append(str)
				}
			})
		})

	})
</script>
	<script>
		onload=function () {
			new Pagination({
				element: '#paging', // 元素        
				type: 1, // 样式类型，可选[1,2]      
				pageIndex: '${pages.getPageNum()}', // 初始页码       
				pageSize: '${pages.getPageSize()}', // 每页数量       
				pageCount: '${pages.getPages()}', // 页码数量       
				total: '${pages.getTotal()}', // 数据总条数        
				jumper: true, // 显示输入框跳转        
				singlePageHide: false, // 只有一页时不显示分页       
				prevText: '上一页', // 上一页文字        
				nextText: '下一页', // 下一页文字       
				disabled: true, // 是否显示禁用        
				currentChange: function(index) {
					// 页码改变时回调         
					location='${project_name}/back_type/show/'+index
				}
			});
		}
	</script>
</head>
<body>
<jsp:include page="public_header.jsp" />
<div id="main" class="wrap">
	<c:import url="public_menu.jsp"></c:import>
	<div class="main">
		<h2>分类管理</h2>
		<div class="manage">
			<table class="list">
				<tr>
					<th>分类名称</th>
					<th>操作</th>
				</tr>
				<c:forEach items="${firstType}" var="f">
					<tr>
						<td colspan="2">
							<details style="padding-left:50px; ">
								<summary>${f.name}
									<input class="firstTypeId" hidden readonly value="${f.id}">
									<span style="float: right;">
									<a href="${project_name}/back_type/showOneFirstType/${f.id}">修改</a>
							 		<a href="${project_name}/back_type/delFirstType/${f.id}" onclick="return confirm('确定删除?')">删除</a>
							 		</span>
								</summary>
							</details>
						</td>
					</tr>
				</c:forEach>

			</table>
		</div>
		<div id="paging"></div>
	</div>
	<div class="clear"></div>
</div>
<div id="footer">
	Copyright &copy; 2010 极客营 All Rights Reserved. 京ICP证801001号
</div>
</body>
</html>
